app.config([
    '$stateProvider', '$urlRouterProvider', '$controllerProvider', '$compileProvider', '$filterProvider', '$provide', '$ocLazyLoadProvider', 'JS_REQUIRES',
    function($stateProvider, $urlRouterProvider, $controllerProvider, $compileProvider, $filterProvider, $provide, $ocLazyLoadProvider, jsRequires) {
        var loadSequence;
        loadSequence = void 0;
        app.controller = $controllerProvider.register;
        app.directive = $compileProvider.directive;
        app.filter = $filterProvider.register;
        app.factory = $provide.factory;
        app.service = $provide.service;
        app.constant = $provide.constant;
        app.value = $provide.value;
        $ocLazyLoadProvider.config({
            debug: false,
            events: true,
            modules: jsRequires.modules
        });
        loadSequence = function() {
            var _args;
            _args = void 0;
            _args = arguments;
            return {
                deps: [
                    '$ocLazyLoad', '$q',
                    function($ocLL, $q) {
                        var i, len, promise, promiseThen, requiredData;
                        i = void 0;
                        len = void 0;
                        promise = void 0;
                        promiseThen = void 0;
                        requiredData = void 0;
                        promise = $q.when(1);
                        promiseThen = function(_arg) {
                            if (typeof _arg === 'function') {
                                return promise.then(_arg);
                            } else {
                                return promise.then(function() {
                                    var nowLoad;
                                    nowLoad = void 0;
                                    nowLoad = requiredData(_arg);
                                    if (!nowLoad) {
                                        console.log('Route resolve: Bad resource name [' + _arg + ']');
                                    }
                                    return $ocLL.load(nowLoad);
                                });
                            }
                        };
                        requiredData = function(name) {
                            var m;
                            m = void 0;
                            if (jsRequires.modules) {
                                for (m in jsRequires.modules) {
                                    m = m;
                                    if (jsRequires.modules[m].name && jsRequires.modules[m].name === name) {
                                        return jsRequires.modules[m];
                                    }
                                }
                            }
                            return jsRequires.scripts && jsRequires.scripts[name];
                        };
                        i = 0;
                        len = _args.length;
                        while (i < len) {
                            promise = promiseThen(_args[i]);
                            i++;
                        }
                        return promise;
                    }
                ]
            };
        };
        $stateProvider
            .state('tab', {
                url: '/tab',
                abstract: true,
                templateUrl: 'components/tabCtrl/tabCtrl.html',
                resolve: loadSequence('tabCtrl')
            })

        // Each tab has its own nav history stack:

        .state('tab.dash', {
            url: '/dash',
            views: {
                'tab-dash': {
                    templateUrl: 'components/dash/dash.html',
                    resolve: loadSequence('dash')
                }
            }
        })

        .state('tab.chats', {
            url: '/chats',
            views: {
                'tab-chats': {
                    templateUrl: 'components/chats/chats.html',
                    resolve: loadSequence('Chat', 'chats')
                }
            }
        })

        .state('tab.account', {
            url: '/account',
            views: {
                'tab-account': {
                    templateUrl: 'components/account/account.html',
                    resolve: loadSequence('account')
                }
            }
        });

        $urlRouterProvider.otherwise(function($injector, $state) {
            var $localStorage, $state, guide;
            $state = $injector.get("$state");
            $state.go('tab.dash');

        });
    }
]);